<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <div class="box">
        <span>1</span>
        <p>22</p>
    </div>

    <script>


        // 替换
        // 父元素.replaceChild(新的元素，旧的元素)


        // 把box里面的span替换成  h3

        var oBox = document.querySelector('.box') ;
        var oSpan = document.querySelector('span') ;


        var oH3 = document.createElement('h3') ;
        oH3.innerHTML = 666 ;

        oBox.replaceChild(oH3 , oSpan) ;

    </script>
    
</body>
</html>